<template>
  <!-- 底部部分 -->
  <footer class="footer">
    <span class="todo-count">剩余<strong>{{list.length}}</strong></span>
    <ul class="filters" @click="$emit('changetype',type)">
      <li>
        <a @click.prevent="type = 'all'" :class="{selected:type === 'all'}" href="#/">全部</a>
      </li>
      <li>
        <a @click.prevent="type = 'active'" :class="{selected:type === 'active'}" href="#/active">进行中</a>
      </li>
      <li>
        <a @click.prevent="type = 'completed'" :class="{selected:type === 'completed'}" href="#/completed">已完成</a>
      </li>
    </ul>
    <button @click="clear" v-show="showclear" class="clear-completed">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props:{
    list:{
      required:true,
      type:Array
    }
  },
  data() {
    return {
      type:'all'
    }
  },
  methods: {
    clear() {
      this.$emit('hclear')
    }
  },
  computed: {
    showclear() {
      return this.list.some(item => item.isDone)
    }
  },
};
</script>

<style>
</style>